<template>
	<view class="main">
		<view>
			<view class="bgview">
				<view class="topview">
					<view class="top-left"><label class="lab-item-left"><span>{{item.title}}</span></label></view>
					<view v-if="item.salaryMax" class="top-right"><label
							class="lab-item-right">{{item.salaryMin}}~{{item.salaryMax}}{{item.unit}}</label></view>
					<view v-else class="top-right"><label class="lab-item-right">{{item.salaryMin}}{{item.unit}}</label>
					</view>
				</view>
				<view class="buttomview">
					<view class="addr">
						<view>工作地点:{{item.address}}</view>
						<view>{{item.publisher}}于{{item.createTime}}发布</view>
					</view>
				</view>
				<view class="tag_container">
					<zyTag ref="zyAddTag" v-for="(item,index) in taglist" :text="item" addible />
				</view>
				<view class="centerview">
					<text style="font-size: 26rpx;color: #424242;">{{item.workContent}}</text>
				</view>
				<view v-if="item.lat">
					<map style="width: 100%; height: 200px;" :latitude="item.lat" :longitude="item.lon"
						:markers="covers">
					</map>
				</view>
				<view class="lineview"></view>
			</view>
		</view>
		<view class="zanweiview">

		</view>
		<view class="tool_bottom" v-if="item.contractMethod==2 & item.userId != userid">
			
			<view class="tool_bottom" v-if="item.hasRegister==0">
				<view class="fabuview">
					<button class="callbtn" @click="playtel(item)">电话联系</button>
				</view>
				<view class="fabuview">
					<button class="callbtn" @click="baoming(item)">立即报名</button>
				</view>
			</view>
			<view class="tool_bottom" v-if="item.hasRegister==1">
				<view class="fabuview">
					<button class="callbtn" @click="playtel(item)">电话联系</button>
				</view>
				<view class="fabuview">
					<button class="callbtn">已报名</button>
				</view>
			</view>
		</view>
		<!-- ===================== -->
		<view class="tool_bottom" v-if="item.contractMethod==0 & item.userId != userid">
			<view class="fabuview">
				<button class="callbtn" @click="playtel(item)">电话联系</button>
			</view>
		</view>
		<view class="tool_bottom" v-if="item.contractMethod==1 & item.userId != userid & item.hasRegister==0">
			<view class="fabuview">
				<button class="callbtn" @click="baoming(item)">立即报名</button>
			</view>
		</view>
		<view class="tool_bottom" v-if="item.contractMethod==1 & item.userId != userid & item.hasRegister==1">
			<view class="fabuview">
				<button class="callbtn">已报名</button>
			</view>
		</view>
	</view>
</template>

<script>
	// import Index from "@/common/index-model.js"
	import zyTag from '../../components/zy-tag/zy-tag.vue'
	import Index from "../../common/index-model.js"
	let index = new Index();
	let that = null;
	export default {
		components: {
			zyTag
		},
		data() {
			return {
				item: {},
				taglist: [],
				contractMethod: 0,
				show: true,
				itemId: '',
				userid: ''
			}
		},
		onLoad(option) {
			// console.log('传过来的值是==666666666666666==', option)
			// this.getdataSource(option.index)
			this.itemId = option.cardID
			// this.getdata(option.cardID)
			this.userid = uni.getStorageSync('userid')
			console.log('传过来的值是==666666666666666==', option, this.userid)
		},
		onShow() {
				this.getdata(this.itemId)
		},
		methods: {
			//添加标签input框回车事件
			confirm() {
				this.tagAddList.push(this.addValue)
				this.addValue = ''
			},
			//通用跳转
			NavUrlRd(url) {
				if (uni.getStorageSync('token')) {
					index.navigate_to(url)
				} else {
					uni.navigateTo({
						url: "/pagesC/login/login"
					});
				}
			},
			baoming(item) {
				if (uni.getStorageSync('token')) {
					console.log('报名跳转传惨', this.itemId)

					if (this.item.userId == this.userid) {
						uni.showToast({
							title: '不能联系自己',
							icon: 'none'
						})
					} else {
						uni.navigateTo({
							url: "/pagesC/job/entryJob?data=" + this.itemId
						})
					}
				} else {
					index.navigate_to('../../pagesC/login/login');
				}
			},
			playtel(item) {
				let token = uni.getStorageSync('token')
				if (uni.getStorageSync('token')) {
					let userid = uni.getStorageSync('userid')
					console.log('打电话时的userid是：',userid,'orderid',this.itemId);
					if (this.item.userId == this.userid) {
						uni.showToast({
							title: '不能联系自己',
							icon: 'none'
						})
					} else {
						let orderid = this.itemId
						uni.makePhoneCall({
							phoneNumber: item.contractMobile,
							success: function() {
								let data = {
									userId:userid,
									orderId:orderid
								}
								console.log('打电话时请求的数据是：',data);
								index.getPublicUserMember(data, 'client/contact/phone/callPhone', 'post', res => {
									console.log('添加拨打电话记录成功！');
								})
							},
							fail: function() {
								console.log('拨打电话失败！');
							}
						});
					}
				} else {
					index.navigate_to('../../pagesC/login/login');
				}
			},
			getdata(id) {
				let url = ''
				let token = uni.getStorageSync('token')
				console.log('好活详情',token)
				if(token){
					url = 'client/recuitjob/detail/' + id
					console.log('----------======-------', url)
					index.getPublicUserMember({}, url, 'get', res => {
						if (res.data.code == 200 && res.data.success) {
							this.item = res.data.result
							this.contractMethod = res.data.result.contractMethod
							if (res.data.result.welfares) {
								this.taglist = res.data.result.welfares.split(",") //待完成
								console.log('福利标签', this.taglist)
							}
						} else {
							index.show_tips(res.data.message)
							return false
						}
					})
				}else{
					url = 'client/recuitjob/detailNoSe/' + id
					console.log('----------======-------', url)
					index.getPublicMember({}, url, 'get', res => {
						if (res.data.code == 200 && res.data.success) {
							this.item = res.data.result
							this.contractMethod = res.data.result.contractMethod
							if (res.data.result.welfares) {
								this.taglist = res.data.result.welfares.split(",") //待完成
								console.log('福利标签', this.taglist)
							}
						} else {
							index.show_tips(res.data.message)
							return false
						}
					})
				}
				
				

			},
			onShareAppMessage(res) {
				if (res.from === 'button') { // 来自页面内分享按钮
				}
				return {
					title: '【天下工人】',
					path: '/pagesB/jobinfo/jobLeavetwoInfo?' + '&cardID=' + uni.getStorageSync('cardID'),
					imageUrl: 'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230327160119.png'
				}
			},
			onShareTimeline(res) {
				return {
					title: '【天下工人】',
					query: '/pagesB/jobinfo/jobLeavetwoInfo?' + '&cardID=' + uni.getStorageSync('swiper_info'),
					imageUrl: 'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230327160119.png'
				}
			}
		}
	}
</script>
<style>
	@import url("@/static/css/publics.css");
	@import url("@/static/css/myfollow.css");
</style>
<style lang="scss">
	/* 白色 */
	$zy-classic-white: #ffffff;

	/* 灰色 */
	$zy-classic-grey: #e9e9e9;
	$zy-dark-grey: #999999;

	.container {
		width: 100%;
		height: 100vh;
		background-color: $zy-classic-white;
	}

	.text {
		padding: 20rpx 0 0 20rpx;
		font-size: 26rpx;
		color: $zy-dark-grey;
	}

	.tag_container {
		display: flex;
		align-items: center;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.zy_tag_add {
		width: 150rpx;
		height: 50rpx; //medium：45rpx；small：40rpx；mini：35rpx
		padding: 5rpx 15rpx;
		margin: 5rpx 8rpx;
		border: 1rpx solid $zy-classic-grey;
		border-radius: 10rpx;
		text-align: center;
	}

	.zy_tag_add_input {
		margin: auto;
		width: 150rpx;
		height: 50rpx; //medium：45rpx；small：40rpx；mini：35rpx
		font-size: 28rpx; //medium：26rpx；small：24rpx；mini：22rpx
	}

	page {
		width: 100%;
		height: 100%;
		background-color: #ffffff;
	}

	.tag {
		// margin: 10px;
		margin-top: 10px;
		margin-right: 10px;
		margin-bottom: 20px;
	}

	.callbtn {
		// margin-right: 15px;
		// width: 80px;
		// height: 30px;
		// font-size: 13px;
		// // margin: auto;
		// text-align: center;
		// // letter-spacing: 3px;
		// // text-indent: 3px;
		// writing-mode: vertical-lr;
		margin-top: -10rpx;
		height: 45px;
		line-height: 60rpx;
		width: 100%;
		text-align: center;
		color: #fff;
		border-radius: 8rpx;
		background: #0575ff;
		font-size: 16px;
		border: none;
		box-shadow: none;
	}

	.zanweiview {
		height: 150px;
	}

	.tool_bottom {
		width: 100%;
		padding: 10px;
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-top: 1px solid #e3e3e3;
		background-color: white;
		height: 50px;
		
		.fabuview {
			height: 45px;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 3px;
			background-color: #0575FF;
			width: 100%;
			margin-left: 20px;
			margin-right: 20px;
			.callbtn {
				padding: 10px;
				height: 45px;
				// line-height: 60rpx;
				width: 100%;
				text-align: center;
				color: #fff;
				// border-radius: 8rpx;
				background: #0575ff;
				font-size: 16px;
				border: none;
				box-shadow: none;
				border-width: 0px;
			}

			// .lab-item-left {
			// 	text-align: center;
			// 	color: white;
			// }
		}

	}

	.contentLab {
		overflow: hidden;
		-webkit-line-clamp: 2;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.lineview {
		background-color: #F6F6F6;
		width: 100%;
		height: 5px;
	}

	.centerview {
		margin: 10px;
		background-color: white;
		// margin-top: 15px;
		// margin-: 15px;
	}

	.buttomview {
		margin-left: 10px;
		padding-bottom: 10px;
		background-color: white;
		display: flex;
		flex-direction: row;
		// height: 45px;
		margin-top: 20px;

		.addr {
			display: flex;
			flex-direction: column;
			color: #a1a1a1;
			font-size: 24rpx;
			// margin-top: 20rpx;
			// width: 65%;
			// ::v-deep {
			// 	.u-icon {
			// 		margin-right: 60px;
			// 	}
			// }
		}

		.callview {
			// background-color: #a1a1a1;
			// padding: 15px;
			margin-top: 15px;
			height: 30px;
			// margin-left: 150px;
			width: 35%;

			.callbtn {
				// margin-right: 15px;
				// width: 80px;
				// height: 30px;
				// font-size: 13px;
				// // margin: auto;
				// text-align: center;
				// // letter-spacing: 3px;
				// // text-indent: 3px;
				// writing-mode: vertical-lr;
				margin-top: -10rpx;
				height: 60rpx;
				line-height: 60rpx;
				width: 180rpx;
				text-align: center;
				color: #fff;
				border-radius: 8rpx;
				background: #0575ff;
				font-size: 28rpx;

			}
		}
	}

	.bgview {
		padding-top: 10px;
		background-color: white;
		display: flex;
		flex-direction: column;
		margin-top: 10px;

		.topview {
			display: flex;
			flex-direction: row;
			height: 30px;

			// justify-items: center;
			.top-left {
				// background-color: yellow;
				background-color: white;
				width: 50%;
				display: flex;
				justify-content: flex-start;
				padding-left: 10px;
				align-items: center;

				// justify-items: center;
				.lab-item-left {
					font-family: PingFang SC-Bold;
					font-weight: bold;
					text-align: left;
					font-size: 16px;
					color: #0F0F0F;
					margin-bottom: 32rpx;
					display: -moz-box;
					// -moz-line-clamp: 2;
					-moz-box-orient: vertical;
					overflow-wrap: break-word;
					word-break: break-all;
					white-space: nowrap; //不换行
					text-overflow: ellipsis; //超出部分省略号
					overflow: hidden;
				}
			}

			.top-right {
				// background-color: goldenrod;
				background-color: white;
				width: 50%;
				display: flex;
				justify-content: flex-end;
				padding-right: 10px;
				text-align: center;
				align-items: center;

				// justify-items: center;
				.lab-item-right {
					font-family: PingFang SC-Bold;
					text-align: right;
					font-weight: bold;
					font-size: 14px;
					color: #0575FF;
					margin-bottom: 32rpx;
					display: -moz-box;
					-moz-line-clamp: 1;
					-moz-box-orient: vertical;
					overflow-wrap: break-word;
					word-break: break-all;
					white-space: normal;
					overflow: hidden;
				}
			}
		}
	}
</style>